
package de.berlin.fu.inf.nbi.rdflinda.primitives;

import java.security.SecureRandom;
import java.util.List;

import org.nlogo.agent.*;
import org.nlogo.agent.Turtle;
import org.nlogo.api.*;

@SuppressWarnings( { "unused", "unchecked" })
public class AgentAccessTest
extends DefaultReporter
{
    @Override
    public strictfp Syntax getSyntax() {
        return Syntax.reporterSyntax(new int[] { Syntax.TYPE_AGENTSET }, Syntax.TYPE_AGENT);
    }

    public Object report(Argument[] arg0, Context arg1)
    throws ExtensionException, LogoException {
        List<Turtle> list = arg0[0].getList();
        for (Turtle turtle : list) {
            List<Turtle> turtlesHere = turtle.getPatchHere().turtlesHere;
            for (Turtle agent : turtlesHere) {
                int agentBit = agent.getAgentBit();
                int breedIndex = agent.getBreedIndex();
                if (breedIndex == 2) {
                    Object variable = agent.variables;
                    try {
                        Turtle homeNode = (Turtle) agent.getVariable("HOME-NODE");
                        if (homeNode == null) {
                            int z = 0;
                        }
                    }
                    catch (AgentException e) {}
                }
            }
        }
        return list.get(new SecureRandom().nextInt(list.size()));
    }

}
